import { cloneDeep, } from 'lodash-es';
import { roleList } from "./role";

export let userList: UserRecord[] = [
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 1, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 2, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 3, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 4, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 5, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 6, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 7, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 8, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 9, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 10, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 11, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 12, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 13, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 14, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 15, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 16, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 17, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 18, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 19, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 20, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 21, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 22, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 23, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 24, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 25, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 26, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 27, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 28, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "管理员", userId: 29, deptId: 103, userName: "admin", nickName: "必哥", email: "bg@163.com", phonenumber: "15888888888", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-08T19:40:19.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 103, parentId: null, ancestors: null, deptName: "研发部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
  {createBy: "admin", createTime: "2024-07-07 17:41:52", updateBy: null, updateTime: null, remark: "测试员", userId: 30, deptId: 105, userName: "bg", nickName: "必哥", email: "bg@qq.com", phonenumber: "15666666666", sex: "1", avatar: "", password: null, status: "0", delFlag: "0", loginIp: "127.0.0.1", loginDate: "2024-07-07T17:41:52.000+08:00", dept: {createBy: null, createTime: null, updateBy: null, updateTime: null, remark: null, deptId: 105, parentId: null, ancestors: null, deptName: "测试部门", orderNum: null, leader: "必哥", phone: null, email: null, status: null, delFlag: null, parentName: null, children: []}, roles: [], roleIds: null, postIds: null, roleId: null, admin: false},
];

const mocks: MockRecord[] = [
  {
    method: "get",
    url: "/api/system/user/list",
    response(option) {
      const copyList = cloneDeep(userList);

      const resList = copyList.splice((option.query.pageNum - 1) * option.query.pageSize, option.query.pageSize);

      const resData: responseType = {
        code: 200,
        msg: "查询成功",
        total: userList.length,
        rows: resList,
      }

      return resData;
    }
  },
  {
    method: "put",
    url: "/api/system/user/resetPwd",
    response(option) {
      const resData: responseType = {
        code: 200 ,
        msg: "操作成功",
      }

      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/user/:userId",
    response(option) {
      const userObj = userList.find(item => item.userId == option.query.userId);

      if (userObj) {
        userObj.roles = [
          {
            "createBy": null,
            "createTime": null,
            "updateBy": null,
            "updateTime": null,
            "remark": null,
            "roleId": 2,
            "roleName": "普通角色",
            "roleKey": "common",
            "roleSort": 2,
            "dataScope": "2",
            "menuCheckStrictly": false,
            "deptCheckStrictly": false,
            "status": "0",
            "delFlag": null,
            "flag": false,
            "menuIds": null,
            "deptIds": null,
            "permissions": null,
            "admin": false
          }
        ]
      }

      const resData: responseType = {
        code: userObj ? 200 : 500,
        msg: userObj ? "查询成功" : "查询失败",
        data: userObj,
        ...(userObj ? {
          postIds: [2],
          posts: [
            {
              createBy: "admin",
              createTime: "2024-07-07 17:41:52",
              updateBy: null,
              updateTime: null,
              remark: "",
              postId: 1,
              postCode: "ceo",
              postName: "董事长",
              postSort: 1,
              status: "0",
              flag: false
            },
            {
              "createBy": "admin",
              "createTime": "2024-07-07 17:41:52",
              "updateBy": null,
              "updateTime": null,
              "remark": "",
              "postId": 2,
              "postCode": "se",
              "postName": "项目经理",
              "postSort": 2,
              "status": "0",
              "flag": false
            },
            {
              "createBy": "admin",
              "createTime": "2024-07-07 17:41:52",
              "updateBy": null,
              "updateTime": null,
              "remark": "",
              "postId": 3,
              "postCode": "hr",
              "postName": "人力资源",
              "postSort": 3,
              "status": "0",
              "flag": false
            },
            {
              "createBy": "admin",
              "createTime": "2024-07-07 17:41:52",
              "updateBy": null,
              "updateTime": null,
              "remark": "",
              "postId": 4,
              "postCode": "user",
              "postName": "普通员工",
              "postSort": 4,
              "status": "0",
              "flag": false
            }
          ],
          roleIds: [2],
          roles: [
            {
              createBy: null,
              createTime: "2024-07-07 17:41:52",
              updateBy: null,
              updateTime: null,
              remark: "普通角色",
              roleId: 2,
              roleName: "普通角色",
              roleKey: "common",
              roleSort: 2,
              dataScope: "2",
              menuCheckStrictly: true,
              deptCheckStrictly: true,
              status: "0",
              delFlag: "0",
              flag: false,
              menuIds: null,
              deptIds: null,
              permissions: null,
              admin: false
            }
          ],
        } : {}),
      }

      return resData;
    }
  },
  {
    method: "delete",
    url: "/api/system/user/:userIds",
    response(option) {
      const userIds = option.query.userIds.split(',');

      const fiList = userList.filter(item => !userIds.includes(String(item.userId)));

      const resData: responseType = {
        code: 200,
        msg: "删除成功",
      }
      return resData;
    }
  },
  {
    method: "post",
    url: "/api/system/user",
    response(option) {
      const newUser = option.body;
      newUser.userId = userList.length + 1;
      userList.unshift(newUser);
      const resData: responseType = {
        code: 200,
        msg: "新增成功",
      }
      return resData;
    }
  },
  {
    method: "put",
    url: "/api/system/user",
    response(option) {
      const newUser = option.body;

      const index = userList.findIndex(item => item.userId == newUser.userId);

      userList.splice(index, 1, newUser);

      const resData: responseType = {
        code: 200,
        msg: "修改成功",
      }

      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/user/authRole/:userId",
    response(option) {
      const newUser = userList.find(item => item.userId == option.query.userId);

      if (!newUser.roleIds) {
        newUser.roleIds = [];
      }

      const copyRoleList = cloneDeep(roleList);

      copyRoleList.forEach(item => {
        item.flag = newUser.roleIds.includes(item.roleId);
      })

      const resData: responseType = {
        code: newUser ? 200 : 500,
        msg: newUser ? "查询成功" : "查询失败",
        user: newUser,
        roles: copyRoleList,
      }
      return resData;
    }
  },
  {
    method: "put",
    url: "/api/system/user/authRole",
    response(option) {
      const newUser = userList.find(item => item.userId == option.query.userId);

      const authRoleIds = (option.query.roleIds?.split(',') || []).map(item => Number(item));

      newUser.roleIds = authRoleIds;

      const resData: responseType = {
        code: 200,
        msg: "操作成功",

      }
      return resData;
    }
  },

]

export default mocks